Skip to content

feat(serial): rpc_validate — typed JSON-RPC schema validator (#698)#714

Merged
zackees merged 1 commit into
mainfrom
feat/698-rpc-validate
Jun 20, 2026
Merged

feat(serial): rpc_validate — typed JSON-RPC schema validator (#698)#714
zackees merged 1 commit into
mainfrom
feat/698-rpc-validate

Conversation

@zackees

@zackees zackees commented Jun 20, 2026

Copy link
Copy Markdown
Member

#698. Centralizes the rpc.discover host-side validator that today lives ad-hoc on the FastLED Python side. Folded into fbuild-serial (per the 'never add a new crate' essential rule) since it sits next to messages.rs's JSON-RPC types and the bring-up orchestrator (#697) is the canonical consumer.

What ships

  • RpcSchema + MethodDecl — typed shape of rpc.discover's response
  • parse_schema_response(&str) — distinguishes InvalidJson, MissingJsonRpc, MissingMethods, DeviceError so callers get actionable failures instead of the cryptic '2 validation errors for RpcSchema: jsonrpc required, methods required' pydantic message FastLED autoresearch emits today (fix(autoresearch/lpc): assert DTR=True + VID:PID port detection (#3300) FastLED#3339)
  • Accepts both canonical envelope shape AND bare schema shape — different firmwares emit different shapes
  • ValidationReport + MethodStatus { Present { params, returns } | Missing } — structured per-method status
  • validate_against_expectedis_passing() iff every expected is Present
  • Display renders the actionable diagnostic the issue specifies

Tests — 12 passed

Canonical envelope + bare schema parses, MissingJsonRpc / MissingMethods / DeviceError / InvalidJson typed errors, all-present passing report, missing-method failing report, device-method-count surfacing for extras, actionable Display for both pass + fail, empty-expected trivial pass.

Out of scope (follow-up)

Closes #698.

#698. Centralizes the rpc.discover host-side validator
that today lives ad-hoc on the FastLED Python side. Folded into
fbuild-serial (per the project's 'never add a new crate' essential
rule) since it sits next to messages.rs's JSON-RPC types and the
bring-up orchestrator (#697) is the canonical consumer.

What ships:

- RpcSchema + MethodDecl — typed shape of rpc.discover's response
- parse_schema_response(&str) -> Result<RpcSchema, SchemaParseError>
  — distinguishes InvalidJson, MissingJsonRpc, MissingMethods,
  DeviceError variants so callers get actionable failures instead of
  the cryptic '2 validation errors for RpcSchema: jsonrpc required,
  methods required' pydantic message FastLED's autoresearch emits
  today (FastLED/FastLED#3339)
- Accepts both canonical envelope shape (result wrapper) AND bare
  schema shape (no envelope) — different firmwares emit different
  shapes; pin both
- ValidationReport + MethodStatus { Present { params, returns } |
  Missing } — structured per-method status with the device's
  signature surfaced when bound
- validate_against_expected(&schema, expected) — builds the report;
  is_passing() iff every expected method is Present
- Display renders the actionable diagnostic the issue specifies:
  'Expected method 'echo' bound — present (signature: int(int))'
  / 'Expected method 'ghost' bound — NOT FOUND in device schema.'
  / 'Device returned N methods total; harness expects M.'

12 unit tests covering: canonical envelope + bare schema parses,
MissingJsonRpc / MissingMethods / DeviceError / InvalidJson typed
errors, all-present passing report, missing-method failing report,
device-method-count surfacing for extras, actionable Display for
both pass + fail, empty-expected trivial pass.

Out of scope (follow-up):
- fetch_schema() doing the actual serial round-trip — lives in
  the bring-up orchestrator (#697) where the connection is already
  established
- Strict signature checking (today the report surfaces the device
  signature but doesn't auto-fail; over-fires on int vs int32_t
- FastLED's autoresearch migrated to consume this module

Closes #698.
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@zackees, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 20 minutes and 52 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c6c75218-e16b-4061-b41c-e24bf4577882

📥 Commits

Reviewing files that changed from the base of the PR and between 0b8aae4 and fe039bf.

📒 Files selected for processing (2)
  • crates/fbuild-serial/src/lib.rs
  • crates/fbuild-serial/src/rpc_validate.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/698-rpc-validate

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees zackees merged commit 4eb3356 into main Jun 20, 2026
85 of 91 checks passed
@zackees zackees deleted the feat/698-rpc-validate branch June 20, 2026 21:37
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

fbuild-rpc-validate: reusable host-side JSON-RPC schema fetch + validate component

1 participant